package com.biz.primus.ms.oms.service.allocation.validator;

import com.biz.primus.common.utils.StringUtil;
import com.biz.primus.ms.oms.dao.po.OmsConsignee;
import com.biz.primus.ms.oms.dao.po.OmsOrder;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 *
 * 收货地址验证器,主要用于验证收货地址是否填写
 *
 * 判断经纬度,如果没有的话 要通过百度地图API反查
 *
 * @author yanweijin
 * @date 2017/11/6
 */
@Component
public class ConsigneeValidator implements OrderValidator{
	@Override
	public VerificationResult validate(OmsOrder order) {
		OmsConsignee omsConsignee= order.getConsignee();
		if(StringUtil.isNullOrEmpty(omsConsignee.getAddress())||StringUtil.isNullOrEmpty(omsConsignee.getMobile())){
			return new VerificationResult(true,"订单收货信息有误,无法自动分单!");
		}
		return new VerificationResult(false,null);
	}

	@Override
	public String getValidatorName() {
		return "consignee";
	}
}
